<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ page import="java.io.PrintWriter" %>
<%@ page import="weaver.general.BaseBean"%>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util"%>

<%
    //获取当前登录id
    String loginid = null;
    Cookie[] cookies = request.getCookies();
    for (Cookie cookie:
            cookies) {
        if ("loginidweaver".equals(cookie.getName())){
            loginid = cookie.getValue();
        }
    }
    if (loginid == null) {
        response.getWriter().write("loginid is null");
        return;
    }
	
    new BaseBean().writeLog("================================查询OA待办用户："+loginid);
    
    String sql = "select count(1) as num from workflow_requestbase t1,workflow_currentoperator t2 where (t1.deleted <> 1 or t1.deleted is null or t1.deleted='') and t1.requestid = t2.requestid and t2.userid = '"+loginid+"' and t2.usertype=0 and (t1.deleted=0 or t1.deleted is null) and ((t2.isremark=0 and (t2.takisremark is null or t2.takisremark=0 )) or t2.isremark in('1','5','7')) and (t1.deleted=0 or t1.deleted is null) and t2.islasttimes=1 and (nvl(t1.currentstatus,-1) = -1 or (nvl(t1.currentstatus,-1)=0 and t1.creater in (3))) and t1.workflowid in (select id from workflow_base where (isvalid='1' or isvalid='3'))";
    new BaseBean().writeLog("================================查询OA待办SQL："+sql);
    RecordSet rs = new RecordSet();
    rs.execute(sql);
    String cut = sql;
    if(rs.next()){
        cut = Util.null2String(rs.getString("num"));
    }
    new BaseBean().writeLog(loginid+"================================OA待办数量:"+cut);
    PrintWriter writer = response.getWriter();
    writer.write(cut);
%>